<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>vue中的Component</title>
</head>

<body>
    <div id="app">
        <my-aa></my-aa>
    </div>
    <script src="node_modules/vue/dist/vue.js"></script>
    <script type="x-template" id="aTemplate">
        <h3 @click="change">{{msg}}</h3>
    </script>
    <!-- script标签也可以换成template标签，这样其实更好，用法一样 -->
    <script>
        new Vue({
            el: "#app",
            components: {
                'my-aa': {
                    template: "#aTemplate",
                    data() { //data必须是一个函数，且要返回一个json对象
                        return {
                            msg: "我是组件AA"
                        }
                    },
                    methods: {
                        change: function () {
                            this.msg = "changed"
                        }
                    }
                }
            }
        });

    </script>
</body>

</html>